<?php
/**
 * Created by PhpStorm.
 * User: 魏爷
 * Date: 2016/4/27
 * Time: 21:47
 */

namespace Admin\Model;

use Think\Model;
use Think\Page;

class BaseModel extends Model
{
    /**
     * 分页查询
     * @param Integer $count 查询数量
     * @return Array
     */
    public function findPage($count = 15)
    {
        $p = $_REQUEST['p'];
        $options = $this->options;
        if (empty($p)) {
            $p = 1;
        }
        //数据总数
        $total = $this->count();
        //分页参数
        $this->page($p, $count);
        $page = new Page($total, $count);
        $res['now_pgae'] = $p;//当前页码
        $res['data'] = $this->select($options);//数据集合
        $res['total'] = $total;//数据总数
        $res['page_count'] = ceil($total / $count);//页码总数
        $res['html'] = $page->show();//分类html
        $data['page_size'] = $count;//当前页面行数
        return $res;
    }
}
